home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- Smaller Installer © 1996 Bill Goodman, All Rights Reserved
- *******************************************************************************
-
- Quickdraw Hook Example
-
- This installer hook procedure checks that the target machine is running System
- 6.0.5 or higher. It also installs the 32-bit Quickdraw file if the target
- machine is not running version 1.2 or higher. The hook procedure installs the
- Quickdraw file by enabling installation group "P" so the installer will install
- the 32-bit Quickdraw file in the system folder.
-
- To build this hook procedure, compile this code and create a code resource
- (Type:SICR, ID:501, non-preloaded, nonpurgeable, unlocked, unprotected,
- non-sysheap). Add this resource to the "QD32Hook.rsrc" file. Copy all the
- resources in "QD32Hook.rsrc" to your installer's resource file.
-
- Add the 32-bit Quickdraw file to your source archive using the following path:
- "{P}:$EXTENSIONS:32-Bit QuickDraw"
-
- ******************************************************************************/
-
- // This file is compatible with version 2.1 of the universal headers
- #include <Dialogs.h>
- #include <GestaltEqu.h>
-
- #ifdef __MWERKS__
- #include <A4Stuff.h>
- #endif
-
- #ifdef THINK_C
- #include <SetUpA4.h>
- #endif
-
- #include "SIHookProc.h"
-
-
- /******************************************************************************
- Function Prototypes
- ******************************************************************************/
- void FirstFunction(void);
-
-
- /******************************************************************************
- Constant Definitions
- ******************************************************************************/
- #define groupPMask 0x8000 // Group "P" selection mask
-
- // Alert Definitions
- #define sysRequiredAlrt 500 // "This application requires version 6.0.5 or newer of the system software."
-
-
- /******************************************************************************
- Variable Definitions
- ******************************************************************************/
- SIHookParmBlk *gParms; // Global pointer to parameter block
-
-
- /*****************************************************************************/
- pascal void main(
- SIHookParmBlk *parmBlk // Pointer to parameter block
- )
- /******************************************************************************
- This is the main entry point for the installer hook procedure.
- ******************************************************************************/
- {
- #ifdef __MWERKS__
- long holdA4;
- #endif
-
- // Set up access to global variables
- #ifdef THINK_C
- RememberA0();
- SetUpA4();
- #endif
-
- #ifdef __MWERKS__
- holdA4 = SetCurrentA4();
- #endif
-
- gParms = parmBlk;
-
- switch (gParms->function)
- {
- case siHookFirst:
- FirstFunction();
- }
-
- // Restore original A4 value
- #ifdef THINK_C
- RestoreA4();
- #endif
-
- #ifdef __MWERKS__
- SetA4(holdA4);
- #endif
- }
-
-
- /*****************************************************************************/
- void FirstFunction(void)
- /******************************************************************************
- Input parameters:
- "targetVRefNum" Volume reference number of target volume
- "groupAPFlags" Groups currently selected
- "groupQUSel"
- "groupVZSel"
- "group32Flags"
- "group64Flags"
- "group96Flags"
- "groupEnvironFlags"
-
- Returns:
- "groupAPFlags" Updated installation groups
- "groupQUSel"
- "groupVZSel"
- "group32Flags"
- "group64Flags"
- "group96Flags"
- "result" Hook result code (siHookNoErr, siHookQuit)
-
- This function is called once when the installer is launched.
- ******************************************************************************/
- {
- long feature;
-
- // Abort if target machine is not running system 6.0.5 or newer
- if (Gestalt(gestaltSystemVersion, &feature))
- goto ForceQuit; // Gestalt could not return system version - force quit
- if (feature < 0x0605)
- { // Newer system required - display alert then force installer to quit
- StopAlert(sysRequiredAlrt, NULL);
- goto ForceQuit;
- }
- if (Gestalt(gestaltQuickdrawVersion, &feature))
- goto ForceQuit; // Gestalt could not return Quickdraw version - force quit
- if (feature < gestalt32BitQD12)
- { // Version is lower than 1.2 - enable installation group "P"
- gParms->groupAPFlags |= groupPMask;
- }
- else
- { // Version is 1.2 or higher - disable installation group "P"
- gParms->groupAPFlags &= ~groupPMask;
- }
- return;
-
- // Error - force installer to terminate
- ForceQuit:
- gParms->result = siHookQuit;
- }